/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package simhya.matheval;

/**
 *
 * @author Luca
 */
public class ConstantNode extends ExpressionNode {
    private int constIndex;
    private SymbolArray constReference;
    String name;


   public ConstantNode(int constIndex, SymbolArray constReference) {
        super(0);
        if (!constReference.checkSymbolIndex(constIndex))
            throw new EvalException("Variable index is wrong");
        this.constReference = constReference;
        this.constIndex = constIndex;
        name = constReference.getName(constIndex);
    }


    @Override
    String getExpressionString(boolean fullNumberRepresentation) {
        return this.name;
    }

    @Override
    void computeValue() {
        super.value = constReference.values[constIndex];
    }

    @Override
    void computeValue(SymbolArray varReference) {
        super.value = constReference.values[constIndex];
    }

    @Override
    void computeValue(int evaluationCode) {
        super.value = constReference.values[constIndex];
    }

    @Override
    void computeValue(SymbolArray varReference, int evaluationCode) {
        super.value = constReference.values[constIndex];
    }

    
}
